/**
 * Created by guodong on 2017/9/11.
 */
'use strict';
angular.module('app')
    .controller('reptileController', [ '$rootScope', '$scope', '$http', '$state','$timeout',
        function($rootScope, $scope, $http, $state, $timeout) {
            $scope.title = '爬虫开关';
            $scope.loading = false;
            $scope.param = { };
            $scope.search = function () {
                $scope.loading = true;
                $.ajax({
                    url : $scope.app.project_name+'/management/reptile/list',
                    data: $scope.param
                }).then(function(result) {
                    console.log(result);
                    $scope.loading = false;
                    if (result.httpCode == 200) {

                        $scope.pageInfo = result.data;

                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }

            $scope.search();

            $scope.oper = function (reptile_thread_flag,$event) {

                $.ajax({
                    url : $scope.app.project_name+'/management/reptile/banEnable',
                    data: {reptile_thread_flag:reptile_thread_flag,systemSettingValue:$event.target.checked?'Y':'N'}
                }).then(function(result) {
                    $scope.loading = false;
                    $scope.alertModal({"content":"操作成功"});
                    if (result.httpCode != 200) {
                        $scope.alertModal(result.msg);
                    }
                    $scope.search();
                });
            }

        } ]);